// 拦截器
import Ajax from '@/utils/fetch'
import Qs from 'qs'

const base = '/tc-recommend'

const dataApi = {
  // 登录
  login (params) {
    return Ajax({
      url: `${base}/login`,
      method: 'post',
      data: params,
      headers: { 'Content-Type': 'application/json' }
    })
  },
  // 推荐
  recommendByReader (params) {
    const data = Qs.stringify(params)
    return Ajax({
      url: `${base}/open-api/readerRecommend?${data}`,
      method: 'get'
    })
  },
  // 推荐首页图书详情
  bookInfo (params) {
    const data = Qs.stringify(params)
    return Ajax({
      url: `${base}/open-api/book/info?${data}`,
      method: 'get'
    })
  },
  // saveSub (params) {
  //   return Ajax({
  //     url: `${base}/keywords/saveSub`,
  //     method: 'post',
  //     data: params,
  //     headers: { 'Content-Type': 'application/json' }
  //   })
  // },
  // 读者订阅词——读者关键词订阅列表
  findKeyWords (params) {
    const data = Qs.stringify(params)
    return Ajax({
      url: `${base}/open-api/keywords/findKeyWords?${data}`,
      method: 'get'
    })
  },
  // 读者订阅词——读者关键词OPAC图书列表
  keywordsList (params) {
    const data = Qs.stringify(params)
    return Ajax({
      url: `${base}/open-api/keywords/info?${data}`,
      method: 'get'
    })
  },
  // 读者订阅词——删除读者关键词订阅
  removeSub (params) {
    const data = Qs.stringify(params)
    return Ajax({
      url: `${base}/open-api/keywords/removeSub/${params.id}`,
      method: 'post',
      data: data
    })
  },
  // 读者订阅词——读者关键词订阅
  saveSub (params) {
    const data = Qs.stringify(params)
    return Ajax({
      url: `${base}/open-api/keywords/saveSub`,
      method: 'post',
      data: data
    })
  },
  // 登录by code
  loginByCode (params) {
    return Ajax({
      url: `${base}/login-from-uwei`,
      method: 'post',
      data: params,
      headers: { 'Content-Type': 'application/json' }
    })
  }
}

export default dataApi
